[APPS] Extract inline backend connection IDs#346
[APPS] Extract inline backend connection IDs#346sdkennedy2 wants to merge 1 commit intosdkennedy2/add-ast-scope-walkerfrom
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 15470da044
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (property.kind !== 'init') { | ||
| continue; |
There was a problem hiding this comment.
Reject accessor connectionId properties
When an action-catalog call uses an accessor like request({ get connectionId() { return CONNECTIONS.HTTP; } }), ESTree reports this as a Property whose kind is get; this branch skips it and the extractor returns no ID, so the manifest can be emitted with an empty allowlist even though runtime reads a connection ID. Since non-literal connection IDs are meant to fail closed, accessor properties named connectionId should throw instead of being ignored.
Useful? React with 👍 / 👎.
| default: | ||
| walkChildNodes(node, scope, importedNames, visit); |
There was a problem hiding this comment.
Track loop and catch shadowing bindings
The generic traversal visits ForOfStatement/ForInStatement/CatchClause children with the unchanged outer scope, so bindings introduced by those constructs don't shadow action-catalog imports. In a backend such as for (const request of handlers) request({ connectionId: id }), that local callback is classified as the imported action-catalog request, which can either fail the build on a dynamic value or pollute the allowlist for a non-action call; please add scoped handling for these binding sites before walking their bodies.
Useful? React with 👍 / 👎.
15470da to
aa6575e
Compare
8a9e82f to
e869c8d
Compare
aa6575e to
902027b
Compare

Motivation
#338 added root
manifest.jsonupload plumbing and requiredallowedConnectionIdsarrays for backend functions, but those arrays are still empty. This PR is the first behavior-changing PR in the new discovery parsing stack: it fills allowlists for the safest static case, inline string literalconnectionIdvalues inside the backend entry module.Changes
Adds a new AST extractor under
backend/ast-parsingthat scans the already-parsed backend file for action-catalog imports and direct action-catalog calls. It recognizes@datadog/action-catalogpackage root and subpaths, supports named/default/namespace imports, ignores type-only imports, and ignores unrelated functions that happen to accept aconnectionIdproperty.The extractor intentionally stays file-local for this PR. It accepts only inline string literals like:
Unsupported action-catalog shapes that could hide a connection ID fail closed, including identifier/template/member/call expressions, object spreads, computed keys, non-object call arguments, and optional action calls. Extracted IDs are deduped, sorted, and assigned as the same file-level union to every backend export from that entry file.
QA Instructions
Run:
I also verified against
/Users/scott.kennedy/dd/test-action-catalog-appby capturing the uploaded ZIP fromnpm run buildand inspectingmanifest.json. The helper pathbackend/helpers/httpProbe.tsusesCONNECTIONS.HTTPthrough an imported helper module, so this PR correctly leavesmoduleGraphHttpProbe.allowedConnectionIdsempty; later stack PRs own same-module and module-graph resolution.Blast Radius
This affects only
@dd/apps-pluginbackend discovery for High Code Apps. The frontend proxy shape is unchanged. The manifest allowlist remains empty unless a backend entry file contains supported inline action-catalogconnectionIdstrings. Known action-catalog calls with unsupported connection ID shapes now fail during build instead of silently emitting an incomplete allowlist.Documentation